package com.cty.A_OutOfMemoryError.B_StackOOM;

/**
 * @Auther: cty
 * @Date: 2020/6/26 21:16
 * @Description: 虚拟机栈和本地方法栈溢出——StackOverflowError
 * @VM Args: -Xss128k
 * @version: 1.0
 */
public class StackSOF {
    private int stackLength = 1;

    public void stackLeak(){
        stackLength++;
        stackLeak();
    }

    public static void main(String[] args) {
        StackSOF sof = new StackSOF();

        try {
            sof.stackLeak();
        } catch (Throwable e){
            System.out.println("stack length:" + sof.stackLength);
            throw e;
        }
    }  // end main()

}  // end StackOOM{}

/**
 * stack length:2098
 * Exception in thread "main" java.lang.StackOverflowError
 * 	at com.cty.OutOfMemoryError.B_StackOOM.StackOOM.stackLeak(StackOOM.java:14)
 * 	at com.cty.OutOfMemoryError.B_StackOOM.StackOOM.stackLeak(StackOOM.java:15)
 * 	at com.cty.OutOfMemoryError.B_StackOOM.StackOOM.stackLeak(StackOOM.java:15)
 * 	at com.cty.OutOfMemoryError.B_StackOOM.StackOOM.stackLeak(StackOOM.java:15)
 */
